package com.nf.health.app.activity.hostopal.view;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.text.Html;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.nf.health.app.R;
import com.nf.health.app.activity.home.MainHomeActivity;
import com.nf.health.app.customview.JustifyTextView;
import com.nf.health.app.glide.GlideUtil;
import com.nf.health.app.models.MengHistoryModel;
import com.nf.health.app.utils.ActivityUtils;

/**
 *我的医院列表
 */

public class ItemLinearView extends LinearLayout implements View.OnClickListener{
    public static String TYPE = "com.nf.type";
    private Activity context;
    private ImageView iv_hostipal_head;
    private TextView tv_hostipal_name,tv_item_type_hostipal_jg,tv_persion_hostipal,tv_user_hostipal_num;
    private View view_line;
    private LinearLayout ll_hotipal_item_service;
    private LayoutInflater inflater;
    private JustifyTextView tv_justtext_detail;
    public ItemLinearView(Activity context) {
        super(context);
        this.context = context;
        initView();
        regisitListener();
    }
    private void regisitListener() {

    }
    private ItemLinearView initView() {
        inflater=(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.item_itemhopstipallinearview, this);
        iv_hostipal_head  = (ImageView) view.findViewById(R.id.iv_hostipal_head);
        tv_item_type_hostipal_jg  = (TextView) view.findViewById(R.id.tv_item_type_hostipal_jg);
        tv_hostipal_name  = (TextView) view.findViewById(R.id.tv_hostipal_name);
        tv_persion_hostipal  = (TextView) view.findViewById(R.id.tv_persion_hostipal);
        tv_user_hostipal_num  = (TextView) view.findViewById(R.id.tv_user_hostipal_num);
        ll_hotipal_item_service  = (LinearLayout) view.findViewById(R.id.ll_hotipal_item_service);
        tv_justtext_detail  = (JustifyTextView) view.findViewById(R.id.tv_justtext_detail);
        return this;
    }

    public ItemLinearView loadData(final MengHistoryModel myHopstipalListBaen){
        GlideUtil.loadNetImgC(context,iv_hostipal_head,myHopstipalListBaen.getHimg()+"",R.drawable.default_head);

        if(!TextUtils.isEmpty(myHopstipalListBaen.getLevel()+"")){
            tv_item_type_hostipal_jg.setVisibility(VISIBLE);
        }else{
            tv_item_type_hostipal_jg.setText(TextUtils.isEmpty(myHopstipalListBaen.getLevel()+"") ?  "" : myHopstipalListBaen.getLevel()+"");
        }
        tv_hostipal_name.setText(TextUtils.isEmpty(myHopstipalListBaen.getHname()) ?  "" : myHopstipalListBaen.getHname());
        String resultdoc = "医生："+myHopstipalListBaen.getDnum()+"名， "+" 专家："+myHopstipalListBaen.getSnum()+"名";
        tv_persion_hostipal.setText(resultdoc);
        String resultdocgzUser = "关注用户： " + myHopstipalListBaen.getUnum()+"名";
        tv_user_hostipal_num.setText(resultdocgzUser);

        String detail = "<b>简介: </b>"+ (TextUtils.isEmpty(myHopstipalListBaen.getGoodremedy()) ? "暂无" : myHopstipalListBaen.getGoodremedy());
        tv_justtext_detail.setText(Html.fromHtml(detail));

        ll_hotipal_item_service.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Bundle bundle = new Bundle();
                bundle.putString(MainHomeActivity.DOCTOR_DETAIL_HID,myHopstipalListBaen.getHid()+"");
               ActivityUtils.showActivity(context,MainHomeActivity.class,bundle);
            }
        });
        return this;
    }
    @Override
    public void onClick(View v) {
        switch (v.getId()){
           /*  case R.id.ll_content_view:
                break;*/
        }
    }

}
